<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>管理中心</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!--[if lt IE 9]>
  	<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  	<![endif]-->
    <link rel="stylesheet" href="#(base)/admin/static/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="#(base)/admin/static/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="#(base)/admin/static/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="#(base)/admin/static/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="#(base)/admin/static/plugins/iCheck/square/blue.css">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
    <script>if(window.top.location.href.indexOf("#(base)/admin/login")==-1){ window.top.location.href="#(base)/admin/login";}</script>
</head>
<body class="hold-transition login-page">
    <div class="login-box">
        <div class="login-logo">
            	后台管理系统
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">
            <p class="login-box-msg">登录系统</p>
            <form id="inputForm">
                <div class="form-group has-feedback">
                    <input type="text" id="username" name="username" value="#(username)" class="form-control" placeholder="用户名">
                    <span class="glyphicon glyphicon-user form-control-feedback"></span>
                </div>
                <div class="form-group has-feedback">
                    <input type="password" id="password" name="password" value="#(password)" class="form-control" placeholder="密码">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                </div>
                <div class="row">
                    <!-- /.col -->
                    <div class="col-xs-4">
                        <button type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
                    </div>
                    <!-- /.col -->
                </div>
            </form>
        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
    <script src="#(base)/admin/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="#(base)/admin/static/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="#(base)/admin/static/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
        $(function() {
        	
        });
    </script>
</body>
</html>
<script type="text/javascript">
$().ready( function() {

	var $inputForm = $("#inputForm");
	var $username = $("#username");
	var $password = $("#password");
	
	// 表单验证
	$inputForm.submit( function() {
		if ($username.val() == "") {
			swal({title:'', text:'请输入您的用户名',icon: 'error'});
			return false;
		}
		if ($password.val() == "") {
			swal({title:'', text:'请输入您的密码',icon: 'error'});
			return false;
		}
		swal({title:'', text:'登录中',icon: 'info',button:false});
		$.ajax({
			url: "#(base)/admin/login/login",
			type: "POST",
			data: $("#inputForm").serialize(),
			dataType: "json",
			cache: false,
			success: function(response) {
				if (response.type=="success") {
					swal({title:'', text:'登录成功',icon: 'success',button:false,timer: 2000}).then(function(){
						location.href="#(base)/admin/index";
					});
				}else{
					swal({title:'', text:response.msg,icon: 'error'});
				}
			},
			error:function(response){
				swal({title:'', text:'系统异常',icon: 'error'});
			}
		});
		return false;
	});
});
</script>